package cn.quevo.cube.provide.define.entity;

import cn.quevo.common.exception.CheckParamsException;
import cn.quevo.common.lang.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.beetl.sql.core.annotatoin.Table;

/**
 * 模型字段 实体BEAN
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2018/12/11 14:57:15
 * @Copyright 湘豫（北京）科技有限公司版权所有.All Rights Reserved.
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table(name = "cube_model_column")
public class CubeModelColumn extends CubeBaseColumn {

    /** 模型ID */
    private Long modelId;
    /** 关联类型CD:00_非关联,20_一对一关联,30_一对多关联 */
    private String relatedTypeCd;

    /**
    /**
     * 新增参数验证
     */
    public void validateCreate() {
        super.validateCreate();
        if (StringUtils.isBlank(this.getModelId())) {
            throw new CheckParamsException(6005, "模型不能为空");
        }
        this.setRelatedTypeCd(StringUtils.isBlank(this.getRelatedTypeCd()) ? "10" : this.getRelatedTypeCd());
    }

    /**
    * 修改参数验证
    */
    public void validateUpdate() {
        super.validateUpdate();
    }
}
